home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
113
/
gfatip10
/
gfatip10.doc
next >
Wrap
Text File
|
1987-10-10
|
4KB
|
91 lines
October 10, 1987
GFATIP10.DOC
by John B. Holder
Senior Software Engineer
Marathon Computer Press
Asst. Sysop on GEnie's MichTron Roundtable
This is the 10th in a planned series of GFA Tip files. The
topic of this issue is utilizing the entire range of ASCII
characters as obtained with the INKEY$ function in GFA Basic. In
this archive you will find the following files:
Inkey.Bas | the demo program
GFATIP10.DOC | This text file
Since the enclosed program file is fairly self explanatory,
I'll keep this file pretty short. I'll give you a short
explanation of what Inkey$ does for you and refer you to the
manual for the complete description. Then I'll tell you what we
have done & how it relates to software utilized in this country
and that in Europe.
Technical aspects of INKEY$
The INKEY$ function within GFA Basic returns a value for a
pressed keyboard key (or combination of keys). This value can be
either 1 or 2 bytes long. If the key pressed falls within 0 and
128 on the ASCII scale, the value will reflect the key pressed and
will be only 1 byte long. However, if the key pressed value is
higher than 128 ASCII, the value becomes a 2 byte long string.
That is where we run into problems. Without our little fix, we
would effectively lose many of the printable characters that are
obtainable with the ST. The reason for this is that the current
versions of GFA Basic pad this two byte value with a preceding
null byte if the ASCII value is >128. In a sense what it is
actually doing is giving you this => CHR$(0) + CHR$(Key Pressed
(minus) 128). Why it utilizes this format, I can't answer.
Unlike the INP(2) function which returns all key values as
obtained from the keyboard, INKEY$ uses this abnormal value
padding scheme.
What's this all about?
A lot of GFA Basic user's have been disgruntled about the
filtering of all of the special printable characters by the INKEY$
function, (myself included). Many applications call for full
keyboard access on the fly. Since this is not possible with
INP(2), the only logical answer was to try to use INKEY$. But
with the filtering that it was doing, it appeared impossible to
accomplish. Since it took on that gloomy aura, and since I was
told that it was a hopeless cause, I decided to tackle the problem
for my own benefit and that of everyone that was interested. By
utilizing GFA Basic's rich suite of commands I found the loophole
to make a FULL KEYBOARD ACCESS routine with INKEY$ a reality.
Since we have the CVI command in GFA Basic it was a snap to pull
off. What CVI does is convert a two byte string into a 16 bit
integer. Well, once I stumbled onto that and realized what INKEY$
was doing, I just put two and two together and converted the
string to an integer and added 128 to it if the value of INKEY$
was more than two bytes long. EUREKA! Some of you might now be
thinking, "Gee you could do that with Right$() and Val() too!".
This is true, but it is much more elegant with CVI and requires
fewer steps too!
The significance is that when used properly, the INKEY$
function can now do everything that Form Input does currently
albeit in a more interactive mode. Not only that, it will allow
our European friends to utilize your programs with the full access
to their character set. Before, the INKEY$ function was screening
out those values.... Not Nice!
Due to time available, I did not have a chance to write a
program that would function in all three resolutions, so I stuck
to the MEDIUM resolution mode. But not to despair, the program is
just a fancy way of getting across the significance of this INKEY$
discovery. I have outlined the procedure very clearly in the
source code for you. Also as an added bonus I've thrown in the
way you find out what version of the Interpreter that you have.
It'll appear in the form of an alert box when you press the ESCAPE
key to exit the program. Enjoy!
John B. Holder
Asst. Sysop On MichTron RT @GEnie
Address => GRIFJOHN